package com.btr.ivle.helper;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseWeblink extends SQLiteOpenHelper {

	private String tableName=null;
	public final String ID="WeblinkID";
	public final String URL="WeblinkURL";
	public final String Description="WeblinkDescription";
	public final String Order="WeblinkOrder";
	public final String CourseCode="WeblinkCourseCode";
	
	public DatabaseWeblink(Context context, String name, CursorFactory factory, int version) {
		super(context, name, factory, version);
		this.tableName = name;
	}
	
	public void onCreate(SQLiteDatabase db) {
		  db.execSQL("CREATE TABLE IF NOT EXISTS "+ tableName +" ( "+ ID + " TEXT PRIMARY KEY , "+
				  CourseCode + " TEXT, " + URL + " TEXT, " + Description + " TEXT, " + Order + " TEXT)"
				  );
	}
	
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		  db.execSQL("DROP TABLE IF EXISTS "+ tableName);
		  onCreate(db);
		 }
}
